package com.hustmed.service.impl;

import com.hustmed.domain.Experiment;
import com.hustmed.domain.HardestSample;
import com.hustmed.domain.Material;
import com.hustmed.domain.Sample;
import com.hustmed.mapper.MaterialMapper;
import com.hustmed.mapper.StatisticsMapper;
import com.hustmed.service.IMaterialService;
import com.hustmed.service.IStatisticsService;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 材料数据Service业务层处理
 *
 */
@Service
public class StatisticsServiceImpl implements IStatisticsService
{
    @Autowired
    private StatisticsMapper statisticsMapper;

    @Autowired
    private ISysDictTypeService dictTypeService;

    @Override
    public int personcount()
    {
        return statisticsMapper.personcount();
    }

    @Override
    public int matcount() {
        return statisticsMapper.matcount();
    }

    @Override
    public int processcount() {
        return statisticsMapper.processcount();
    }

    @Override
    public int expcount() {
        return statisticsMapper.expcount();
    }

    @Override
    public int samplecount() {
        return statisticsMapper.samplecount();
    }

    @Override
    public List<HardestSample> hardestsamplelist() {
        List<HardestSample> hList = new ArrayList<HardestSample>();
        List<SysDictData> data = dictTypeService.selectDictDataByType("process_type");
        for(SysDictData i : data){
            Experiment experiment = new Experiment();
            experiment.setProcess(i.getDictValue());
            List<HardestSample> tempList = statisticsMapper.hardestsamplelist(experiment);
            if(tempList.size()>0) {
                tempList.get(0).setProcessName(i.getDictLabel());
                hList.add(tempList.get(0));
            }
        }
        return hList;
    }


}
